<template>
    <div >
        <el-form :model="form" label-width="120px">
            <el-form-item label="星期选择：" >

                <el-checkbox-group v-model="form.wk">
                    <el-checkbox label="星期一" />
                    <el-checkbox label="星期二" />
                    <el-checkbox label="星期三" />
                    <el-checkbox label="星期四" />
                    <el-checkbox label="星期五" />
                    <el-checkbox label="星期六" />
                    <el-checkbox label="星期日" />
                </el-checkbox-group>
            </el-form-item>
            <el-form-item label="小时选择：">
                每
                <el-select v-model="form.hour" placeholder="Select" style="width:80px">
                    <el-option
                    v-for="item in [1,2,3,4,5,6,7,8,9,10,11,12]"
                    :key="item"
                    :label="item"
                    :value="item"
                    />
                </el-select>小时，备份一次
            </el-form-item>
            <el-row>
                <el-button type="primary" icon="el-icon-check" @click="saveData" size="medium" style="margin-left:120px;">保 存</el-button> 
            </el-row>
            <el-row>
                <div style="color:#ccc;font-size:10px;margin:20px 0 0 50px;display:none;">需要提前配置：mysqldump，cmd命令。</div>
            </el-row>
        </el-form>
    </div>
</template>
<script lang="ts">
import { ElMessageBox } from 'element-plus';   
import { defineComponent , reactive, toRefs } from 'vue'
export default defineComponent({
    setup(props,context) {
        let state = reactive({
            form: {
                wk:[],
                hour:1,
            },
            isNew: false,
            tqrs:[]
        });
        //父级组件刷新数据
        function initData(row:any,isNew:boolean){
            if(isNew){
                state.isNew = true;
                state.form = {
                    wk:[],
                    hour:1,
                }
            }else{
                state.isNew = false;
                state.form = row;
            }
		}
        function saveData(){
            if(state.form.wk.length == 0){
                ElMessageBox({ message: '请输选择星期！', type: 'error' });
                return;
            }
            context.emit('saveBakConfig',state.form,state.isNew);
        }
        return{
            initData,
            saveData,
            ...toRefs(state)
        }
    },
})
</script>
